<?php


namespace app\mall\controller;

use app\mall\model\Merchant;
use app\Utils\Util;
use think\App;

class AppController extends BaseController
{
    protected $mall;
    protected $menus;

    public function __construct(App $app)
    {
        parent::__construct($app);
        $param = $app->request->param();
        if (!empty($param['access_token'])) {
            $data = checkToken($param['access_token']);
            if ($data['code'] == 1) {

                $array = Util::getModelJson($data['data']);
                $this->mall = Merchant::getMerchantWhere([['user_id', '=', $array['uid']]]);
            } else {
                header('Content-Type:application/json; charset=utf-8');
                echo json_encode(['code' => self::CODE_LOGIN, 'msg' => $data['msg']]);
                exit();
            }
        } else {
            header('Content-Type:application/json; charset=utf-8');
            echo json_encode(['code' => self::CODE_LOGIN, 'msg' => "token无效"]);
            exit();
        }
    }
}